package pack1;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
/**
 * @author wenze-zero
 */
public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket ss=new ServerSocket(10086);
        Socket a = ss.accept();
        InputStream is = a.getInputStream();
        byte[] bys=new byte[1024];
        String data=new String(bys,0,is.read(bys));
        OutputStream os=a.getOutputStream();
        if (data.equals("admin/123456")){
            os.write("accept".getBytes());
            byte[] bt=new byte[2];
            String dat=new String(bt,0,is.read(bt));
            if (dat.equals("1")){
                System.out.println("文件传输");
            }
            else {
                System.out.println("数据库查询");
            }
            os.write("finish".getBytes());
        }
        else {
            os.write("refuse".getBytes());
            ss.close();
            a.close();
            is.close();
        }

    }
}
